package Ep06_BinaryTree.DFS.T3_0145;

import Ep06_BinaryTree.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Jimmy Zhan WORKSTATION
 * @date 2023/4/17 10:31
 * 说明：后续遍历  ——  递归写法
 */

public class PostOrderTraversal_recursion {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> res = new ArrayList<>();
        postOrder(root, res);
        return res;
    }
    public void postOrder(TreeNode root, List<Integer> res){
        if (root != null){
            postOrder(root.left, res);
            postOrder(root.right, res);
            res.add(root.val);
        }

    }
}
